package szkeleton;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class DoorView implements Paintable 
{
	private Door door;
	public DoorView(Door d)
	{
		door = d;
	}
	
	@Override
	public void Paint(Graphics2D g, Point start, Point end) 
	{
		if (door.isOpen())
			{
			BufferedImage img = null;
			try
			{
				img = ImageIO.read(new File("./img_res/door_open.png"));
			}
			catch (Exception e)
			{
				Gamelogic.getController().getView().showError(e.getMessage());
				//e.printStackTrace();
			}
			g.drawImage(img, start.x, start.y, end.x-start.x, end.y-start.y, Color.white, null);
			}
		else
		{
			BufferedImage img = null;
			try
			{
				img = ImageIO.read(new File("./img_res/door_closed.png"));
			}
			catch (Exception e)
			{
				Gamelogic.getController().getView().showError(e.getMessage());
				//e.printStackTrace();
			}
			g.drawImage(img, start.x, start.y, end.x-start.x, end.y-start.y, Color.white, null);
		}
	}
}
